from pydantic import BaseModel, EmailStr
from typing import Optional,List

class UserCreate(BaseModel):
    first_name: str
    last_name: str
    email: EmailStr
    password: str


class UserLogin(BaseModel):
    email: EmailStr
    password: str


class UserUpdate(BaseModel):
    first_name: Optional[str]
    last_name: Optional[str]
    password: Optional[str]


class UserLoginResponse(BaseModel):
    token: str
    user: dict

class UserInfoResponse(BaseModel):
    first_name: Optional[str]
    last_name: Optional[str]
    email: str
    role_name: Optional[str]
    permission_ids: List[int]

    class Config:
        from_attributes = True


class ChangePasswordRequest(BaseModel):
    old_password: str
    new_password: str



# user_schema.py
class UserPermissionInfo(BaseModel):
    firstname: str
    lastname: str
    email: str
    permission: str

    class Config:
        from_attributes = True



class UpdateUserInfoRequest(BaseModel):
    first_name: Optional[str] = None
    last_name: Optional[str] = None
    email: Optional[str] = None

    

class UserWithPermissionsResponse(BaseModel):
    userId: str
    firstName: str
    lastName: str
    email: str
    permissions: List[str]

    class Config:
        from_attributes = True

class UpdateUserPermissionsRequest(BaseModel):
    email: EmailStr
    permission_ids: List[int]